package org.example.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.bean.StudentInfo;
import org.example.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceImpl implements StudentService{

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public StudentInfo addStudentInfo(StudentInfo studentInfo) {
        // 调用 StudentMapper 的插入方法
        studentMapper.insert(studentInfo);
        return studentInfo;
    }

    @Override
    public StudentInfo getByExamNumber(String examNumber) {
        QueryWrapper<StudentInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("exam_number", examNumber);
        return studentMapper.selectOne(queryWrapper);
    }

    @Override
    public void updateById(StudentInfo student) {
        studentMapper.updateById(student);
    }

}
